package com.cn.jinl.controller;


import com.cn.jinl.api.IOnDutyPersonService;
import com.cn.jinl.domain.OnDutyPerson;
import com.cn.jinl.utils.CommonUtil;
import com.cn.jinl.utils.JsonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/onduty")
public class OnDutyPersonController {

    @Autowired
    private IOnDutyPersonService onDutyPersonService;

    @RequestMapping("/getOnDutyPersonList/{frontToken}")
    @ResponseBody
    public JsonResponse<List<OnDutyPerson>> getOnDutyPersonList(@PathVariable(value = "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<List<OnDutyPerson>> response = new JsonResponse<>();
        List<OnDutyPerson> onDutyPeoples = onDutyPersonService.getOnDutyPersonList();
        response.setResult(onDutyPeoples);
        response.setSuccess(true);
        return response;
    }

    @RequestMapping("/updateOnDutyPerson/{frontToken}")
    @ResponseBody
    public JsonResponse<String> updateOnDutyPerson(OnDutyPerson onDutyPerson, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = onDutyPersonService.updateOnDutyPerson(onDutyPerson);
        return CommonUtil.getResponseData(response,result);
    }

}
